package com.pzsh.redis;

import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
 * Created by Harry on 2018/11/9.
 */
public interface IRedisService {

    /**
     * Gets key.
     *
     * @param key the key
     * @return the key
     */
    String getString(String key);

    /**
     * Delete key.
     *
     * @param key the key
     */
    void deleteString(String key);

    /**
     * Sets key.
     *
     * @param key   the key
     * @param value the value
     */
    void setString(String key, String value);

    /**
     * Sets key.
     *
     * @param key     the key
     * @param value   the value
     * @param timeout the timeout
     * @param unit    the unit
     */
    void setString(String key, String value, final long timeout, final TimeUnit unit);

    /**
     * 设置键过期时间
     *
     * @param key
     * @param timeout
     * @param unit
     */
    void expireKey(String key, final long timeout, final TimeUnit unit);


    /**
     * 检查key是否存在，返回boolean值
     *
     * @param key
     * @return
     */
    boolean hasKey(String key);

    /**
     * keys key.
     *
     * @param key the key
     * @return result
     */
    Set<String> keys(String key);

    /**
     * 自增+1
     *
     * @param key
     */
    void increment(String key);

    /**
     * 自减 -1
     *
     * @param key
     */
    void decrease(String key);

}
